#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#define endl "\n"
using namespace std;
int a[200000];
int main()
{
	
	int t, n1, n2,x,k=0,kkkk=-1;
	cin >> t;
	while (t--)
	{
		kkkk = -1;
		cin >> n1 >> n2;
		memset(a, 0, sizeof a);
		for (int i = 0; i < n1; i++)
		{
			cin >> a[i];
		}
		while (n2--)
		{    
			cin >> x;
			if (x >= kkkk&&kkkk!=-1)
			{
				cout << n1 << " ";
				continue;
			}
			k = 0;
			for (int i = 0; i < n1; i++)
			{
				k++;
				if (x < a[i])
				{
					cout << k-1 <<" ";
					break;
				}
				if (i == n1 - 1)
				{
					cout << n1 <<" ";
					kkkk = x;
				}	

			}

		}

	}
	return 0;
}
